<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="pojo.User" %>
<%@ page import="pojo.EUserType" %>
<%@ page import="utils.db.impl.UserFetcher" %>
<%@ page import="java.util.List" %>
<script  type="text/javascript" src="js/clearText.js"></script>

<%
User user=(User)session.getAttribute("user");

%>
<%if (session.getAttribute("user") == null) {%>
<h1>Brak dostępu do tej strony!</h1>
<%}else{ 
%>
<h1>Dodawanie urządzenia</h1>
<div id="gallery_container">
<h3>Dodaj urządzenie do bazy</h3>

<form action="AddDeviceServlet" method="POST">
<table>
			<tr>
			<td><label class="panel" for="login">Użytkownik: </label></td>
			<td>
				<div class="styled-select">
				<select name="userId" id="userId">
				<option value="0">Wybierz użytkownika... </option>
				<%
				UserFetcher fetcher = new UserFetcher();
				List<User> users = fetcher.getUsers(EUserType.CLIENT); 
				for(int i=0;i<users.size();i++){
				%>
				<option value="<%=users.get(i).getId()%>"><%=users.get(i).getFirstName()%> <%=users.get(i).getLastName()%> - <%=users.get(i).getEmail()%></option>
				<%} %>
				</select>
				</div>
			</td>
			</tr>
			<tr>
			<td><label class="panel" for="login">Typ urządzenia: </label></td>
			<td>
			<div class="styled-select">
				<select name="deviceType" id="deviceType">
				<option value="0">Wybierz typ... </option>
				<option value="PC">PC </option>
				<option value="LAPTOP">LAPTOP </option>
				<option value="MONITOR">MONITOR </option>
				<option value="PRINTER">DRUKARKA </option>
				<option value="OTHER">INNE </option>
				</select>
			</div>
			</td>
			</tr>
		
			<tr>
			<td><label class="panel" for="login">Opis usterki: </label></td>
			<td>
			<textarea rows="10" cols="50" name="desc" id="desc" onfocus="clearText(this)" onblur="clearText(this)">Opis urządzenia...</textarea>
			</td>
			</tr>
			
</table>
<center><input type="submit" id="submit" class="styled-button-3" value="Dodaj" /></center>
</form>
													<%
		if (session.getAttribute("warning") != null) {
	%>
	<span><%= session.getAttribute("warning") %></span> 
	<%
		session.removeAttribute("warning");
		}
	%>

</div>
<%} %>
